package gdou.gym.socket;



public class SocketResponseEntry {

    public static final SocketResponseEntry USER_REQUEST_FAIL =
            new SocketResponseEntry(null, SocketResponse.USER_REQUEST_FAIL);
    public static final SocketResponseEntry USER_REQUEST_SUCCESS =
            new SocketResponseEntry(null, SocketResponse.USER_REQUEST_SUCCESS);
    public static final SocketResponseEntry ADMIN_REQUEST_SUCCESS = new SocketResponseEntry(null, SocketResponse.ADMIN_REQUEST_SUCCESS);
    public static final SocketResponseEntry ADMIN_REQUEST_FAIL = new SocketResponseEntry(null, SocketResponse.ADMIN_REQUEST_FAIL);


    private final Object data;

    private final int code;
    private final String msg;

    public SocketResponseEntry(Object data, SocketResponse response) {
        this.data = data;
        this.code = response.code;
        this.msg = response.msg;
    }

    public Object getData() {
        return data;
    }


    public int getCode() {
        return code;
    }


    public String getMsg() {
        return msg;
    }


    public enum SocketResponse {
        //用于成功接受到用户请求，并成功写入数据库向用户回复
        USER_REQUEST_SUCCESS(200, "申请成功，等待管理员回应!"),
        //用于成功接受到用户请求，但因为余量不足而回复
        USER_REQUEST_FAIL(300, "申请失败,余量不足或联系管理员!"),
        //用于成功写入数据库向管理员发送请求
        SEND_REQUEST_TO_ADMIN(100, "新的申请"),
        //用于管理员审核后向用户回应
        ADMIN_RESPONSE(400, "审核完成!"),
        //用于管理员审核后向管理员回应
        ADMIN_REQUEST_SUCCESS(200, "处理成功!"),
        ADMIN_REQUEST_FAIL(300, "更新失败，数据状态不符合!,请重新申请!");


        private final int code;
        private final String msg;


        SocketResponse(int code, String msg) {
            this.code = code;
            this.msg = msg;
        }


    }
}


